Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FrameworkBundle][Routing] Add a new tag to be able to use a private service as a service route loader #30926

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Apr 6, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #30402
License MIT
Doc PR symfony/symfony-docs#11337

#eufossa

This PR adds a new tag routing.route_loader autoconfigured thanks to a new ServiceRouterLoader interface to be able to use private route loader services.

The deprecation layer is done through a temporary container that will be removed in 5.0.

TODO :

  • Changelog and upgrade entry
  • Doc PR

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changelog+upgrade files need an update also

@fancyweb
Copy link
Contributor Author

fancyweb commented Apr 7, 2019

@nicolas-grekas I added the UPGRADE entries already.

For the CHANGELOG of the Routing component there is nothing to say IMO. We added a marker interface, an instantly deprecated / internal class, and a compiler pass used by the Framework Bundle 😕

@javiereguiluz
Copy link
Member

Ping @fancyweb. Will you have some time to make the last requested changes? It'd be nice to have this for Symfony 4.3. Thanks!

@fancyweb
Copy link
Contributor Author

I will definitely finish this work before the end of the month.

@fancyweb fancyweb force-pushed the service-router-loader-private-service- branch 2 times, most recently from 3a30564 to 9c5e31a Compare April 29, 2019 16:43
<service id="routing.loader.service" class="Symfony\Component\Routing\Loader\DependencyInjection\ServiceRouterLoader">
<tag name="routing.loader" />
<argument type="service" id="service_container" />
<argument type="service" id="routing.loader.service.container" />
Copy link
Contributor Author

@fancyweb fancyweb Apr 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 5.0, replace this argument with the above tagged locator.

@chalasr
Copy link
Member

chalasr commented May 5, 2019

Although I find route loader more clear, naming should be consistent between the interface and the tag (RouterLoader vs RouteLoader). We should stick with the current naming and rename the tag to routing.router_loader IMHO

@fancyweb fancyweb force-pushed the service-router-loader-private-service- branch from 9c5e31a to 0bb19b7 Compare May 5, 2019 20:22
@chalasr chalasr modified the milestones: next, 4.3 May 5, 2019
UPGRADE-4.3.md Outdated
@@ -123,6 +123,7 @@ Routing
options have been deprecated.
* Implementing `Serializable` for `Route` and `CompiledRoute` is deprecated; if you serialize them, please
ensure your unserialization logic can recover from a failure related to an updated serialization format
* Not tagging the route loader services with `routing.router_loader` has been deprecated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

route loader vs router_loader

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think router loader is way better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, if the "public" name is now router loader, I guess we should update the whole documentation page (https://symfony.com/doc/current/routing/custom_route_loader.html)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and I meant route loader, sorry

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean you want to move back to the original tag name routing.route_loader?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, let's rename the interface + existing implementation, I suggest deprecating ServiceRouterLoader in favor of ContainerRouteLoader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT of renaming everything in another PR after this one is merged for clarity ? First, finish this one (I just need to rename the tag back to routing.route_loader). Then, another one of pure refacto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

friendly ping @fabpot @chalasr, would be cool to have this in 4.3

@fabpot fabpot modified the milestones: 4.3, next May 6, 2019
@fancyweb fancyweb force-pushed the service-router-loader-private-service- branch from 0bb19b7 to 205497b Compare May 6, 2019 11:55
*
* @deprecated since Symfony 4.3, to be removed in 5.0
*/
class ServiceRouterLoaderContainer implements ContainerInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RouterLoaderContainer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fabpot added a commit that referenced this pull request May 13, 2019
…gged locators (nicolas-grekas)

This PR was merged into the 4.3 branch.

Discussion
----------

[DI] default to service id - *not* FQCN - when building tagged locators

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

While reviewing #30926 I realized that defaulting to the FQCN is a shortcut that isn't useful enough.
Defaulting to the service id provides the same experience in practice because service ids are FQCN by default.
But when they aren't, the service id is the proper index to default to when building the locator.

Commits
-------

52e827c [DI] default to service id - *not* FQCN - when building tagged locators
@nicolas-grekas
Copy link
Member

#31463 is now merged, this can be rebased to leverage it and take comments into account. Thanks :)

@fancyweb
Copy link
Contributor Author

I'm closing here becaus it's a mess and I will reopen new splitted PRs 👀

@fancyweb fancyweb closed this Jul 17, 2019
@fancyweb fancyweb deleted the service-router-loader-private-service- branch July 18, 2019 13:28
nicolas-grekas added a commit that referenced this pull request Jul 23, 2019
…eLoader in favor of ContainerLoader and ObjectLoader (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[Routing] Deprecate ServiceRouterLoader and ObjectRouteLoader in favor of ContainerLoader and ObjectLoader

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #30926 (comment)
| License       | MIT
| Doc PR        | -

This PR aims at deprecating some things to have a more consistent code.

### ServiceRouterLoader

1. This class actually fetches an object from a container. In #30926 (comment), it was suggested that it should be renamed to `ContainerRouteLoader`. Actually I think it's better to rename it to `ContainerLoader` since all others route loaders does not have "Route" in their name. Let's be consistent!

2. This class is in a `DependencyInjection` sub directory for historical reasons. Let's remove that! It accepts any PSR-11 container.

### ObjectRouteLoader

1. This class has "Route" in its name too. Let's rename it!

2. This class is supposed to be an abstract implementation for "object" loaders to reuse, but in its code it has a lot of references to "services". Let's remove those references! That means renaming some methods, altering messages, etc.. That also means removing the `supports` method from it to let extending classes implement it.

3. IMHO, this abstract implementation is useless. We sould just deprecate the whole class and move the implemention in the `ContainerLoader` class.

Commits
-------

1548101 [Routing] Deprecate ServiceRouterLoader and ObjectRouteLoader in favor of ContainerLoader and ObjectLoader
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Jul 23, 2019
…eLoader in favor of ContainerLoader and ObjectLoader (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[Routing] Deprecate ServiceRouterLoader and ObjectRouteLoader in favor of ContainerLoader and ObjectLoader

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | symfony/symfony#30926 (comment)
| License       | MIT
| Doc PR        | -

This PR aims at deprecating some things to have a more consistent code.

### ServiceRouterLoader

1. This class actually fetches an object from a container. In symfony/symfony#30926 (comment), it was suggested that it should be renamed to `ContainerRouteLoader`. Actually I think it's better to rename it to `ContainerLoader` since all others route loaders does not have "Route" in their name. Let's be consistent!

2. This class is in a `DependencyInjection` sub directory for historical reasons. Let's remove that! It accepts any PSR-11 container.

### ObjectRouteLoader

1. This class has "Route" in its name too. Let's rename it!

2. This class is supposed to be an abstract implementation for "object" loaders to reuse, but in its code it has a lot of references to "services". Let's remove those references! That means renaming some methods, altering messages, etc.. That also means removing the `supports` method from it to let extending classes implement it.

3. IMHO, this abstract implementation is useless. We sould just deprecate the whole class and move the implemention in the `ContainerLoader` class.

Commits
-------

154810119d [Routing] Deprecate ServiceRouterLoader and ObjectRouteLoader in favor of ContainerLoader and ObjectLoader
fabpot added a commit that referenced this pull request Aug 9, 2019
…rs (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle][Routing] Private service route loaders

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30402
| License       | MIT
| Doc PR        | symfony/symfony-docs#11337

Continuation of #30926.

~Please review only the 2nd commit, I'm building this on top of #32582

Commits
-------

64aa2c8 [FrameworkBundle][Routing] Private service route loaders
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Aug 9, 2019
…rs (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle][Routing] Private service route loaders

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony/symfony#30402
| License       | MIT
| Doc PR        | symfony/symfony-docs#11337

Continuation of symfony/symfony#30926.

~Please review only the 2nd commit, I'm building this on top of symfony/symfony#32582

Commits
-------

64aa2c8529 [FrameworkBundle][Routing] Private service route loaders
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants